package com.ruoyi.cms.article.controller;


import com.ruoyi.cms.article.domain.CmsArticle;
import com.ruoyi.cms.article.domain.vo.CmsArticleSearchVo;
import com.ruoyi.cms.article.domain.vo.SiteCmsArticleSelectVo;
import com.ruoyi.cms.article.service.ICmsArticleService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController("SiteCmsArticleController")
@RequestMapping("/site/cms/article")
public class CmsArticleController extends BaseController {


    @Resource
    private ICmsArticleService cmsArticleService;


    @GetMapping("/list")
    public TableDataInfo list(SiteCmsArticleSelectVo vo) {
        startPage();
        List<CmsArticle> list = cmsArticleService.selectCmsArticleVoListForSite(vo);
        return getDataTable(list);
    }


    @GetMapping("/top/list")
    public AjaxResult toplist(SiteCmsArticleSelectVo vo) {
        List<CmsArticle> list = cmsArticleService.selectCmsArticleTopVoListForSite(vo.getTypeId(), vo.getCount());
        return success(list);
    }


    /**
     * 查询
     *
     * @param vo
     * @return
     */
    @GetMapping("/detail")
    public AjaxResult Detail(SiteCmsArticleSelectVo vo) {
        CmsArticle cmsArticle = cmsArticleService.selectCmsArticleDetailForSite(vo.getTypeId(), vo.getArticleId());
        return AjaxResult.success(cmsArticle);
    }


}
